Software Development
Unit Testing with JUnit
Final Exam: Unit Testing
Unit Testing: Advanced Annotations in JUnit
Unit Testing: An Introduction to the JUnit Framework
Unit Testing: Assertions & Assumptions in JUnit
Unit Testing: Executing JUnit Tests
Unit Testing: Parameterized JUnit Tests

Final Exam: Unit Testing

Course Number:
it_fejjm_01_enus
Lesson Objectives

Final Exam: Unit Testing

  • add dependencies for JUnit and Mockito
  • apply the RepeatedTest annotation to run a test case multiple time
  • compile and run enabled test cases in your project using Apache Maven
  • configure a test case to execute only when a specified assumption is satisfied
  • configure mocks with the when().thenReturn() syntax with input arguments
  • configure stubs to throw exceptions
  • create a customized JUnit annotation composed of several built-in annotations
  • create a Java project using an Apache Maven archetype that includes a separate test directory
  • create mocks using the @Mock annotation
  • create partial mocks using spies
  • define the dependencies and configurations for a simple JSF application
  • demonstrate how ordered mocks work
  • describe the libraries and annotations that can be used to define JUnit tests
  • develop test cases that ensure a unit of an app can run within a specified time
  • identify the benefits of using Mockito to mock objects
  • illustrate the nuances of the verify() function
  • implement test cases that verify Boolean data and objects
  • mock objects in a real-world scenario
  • recall how mocks can be used with unit tests
  • recall the benefits of using Mockito to mock objects
  • set JUnit test cases to execute concurrently
  • throw exceptions from methods that return void
  • use Apache Maven to execute only specific test cases based on class name, method name, or tags
  • use assertions in test cases
  • use @ExtendWith to automatically initialize mocks
  • use spies with interfaces
  • use the DisplayName annotation to set a descriptive name for a test case
  • use the @InjectMock annotation to inject mocks
  • use the ValueSource annotation to run a parameterized test case several times for a set of pre-defined parameters
  • work with argument captors

Overview/Description

Final Exam: Unit Testing will test your knowledge and application of the topics presented throughout the Unit Testing track of the Skillsoft Aspire Javanista to Java Master Journey.



Target

Prerequisites: none

Unit Testing: Advanced Annotations in JUnit

Course Number:
it_jpdtcjdj_03_enus
Lesson Objectives

Unit Testing: Advanced Annotations in JUnit

  • discover the key concepts covered in this course
  • use the DisplayName annotation to set a descriptive name for a test case
  • apply JUnit annotations to set test cases to only run on specific operating systems
  • apply JUnit annotations to set test cases to only execute on specific Java runtime environments
  • enable or disable a test case based on system properties or environment variables
  • create a customized JUnit annotation composed of several built-in annotations
  • specify an order for test case executions within a test class
  • set JUnit test cases to execute concurrently
  • summarize the key concepts covered in this course

Overview/Description
Using annotations in JUnit allows you to add a special form of syntactic meta-data to Java source code for better code readability and structure. The aim of this course is to give you hands-on experience with JUnit annotations which allow you to set when and how test-cases should be run. Kick things off with a basic annotation to set the name of a test case that appears in execution summaries. Move on to using annotations that simplify the setting of conditions in which test cases should run - based on the current operating system, JRE version, and even environment variables. Explore the definition of a custom annotation composed of a combination of pre-built annotations. Then, apply annotations that control the order of test case executions and enable parallel runs of tests. When you're done, you'll be able to use JUnit annotations for several useful tasks.

Target

Prerequisites: none

Unit Testing: An Introduction to the JUnit Framework

Course Number:
it_jpdtcjdj_01_enus
Lesson Objectives

Unit Testing: An Introduction to the JUnit Framework

  • discover the key concepts covered in this course
  • describe various aspects of software testing and test-driven development
  • identify the significant features of the JUnit framework that simplify the writing of test cases
  • create a Java project using an Apache Maven archetype that includes a separate test directory
  • recognize what steps may be involved when testing an application without the JUnit framework
  • describe the libraries and annotations that can be used to define JUnit tests
  • run JUnit tests for your application, both collectively and individually
  • structure your test executions by implementing a common set up and clean up method
  • define a common set up and tear down method for all tests in a JUnit class
  • summarize the key concepts covered in this course

Overview/Description
JUnit, an open-source unit testing framework, can be used by Java developers who employ a test-driven development methodology. The platform allows you to write and run tests on sections of code repeatedly. Use this course as a quick theoretical and hands-on introduction to the JUnit framework. Begin by looking at the process of software testing in general, then unit-testing with JUnit in particular. Next, move on to writing a simple Java app for which you will write JUnit test cases to ensure that its functions behave in line with expectations. Moving along, learn how to use annotations to mark out methods as test cases and set up work to be carried out before test case executions and tasks to be performed after they have run. When you're done, you'll be able to get started writing unit tests for your code using the JUnit framework.

Target

Prerequisites: none

Unit Testing: Assertions & Assumptions in JUnit

Course Number:
it_jpdtcjdj_02_enus
Lesson Objectives

Unit Testing: Assertions & Assumptions in JUnit

  • discover the key concepts covered in this course
  • set a test to check that an actual value generated by a unit in an app matches the expected value
  • implement test cases that verify Boolean data and objects
  • develop test cases that ensure a unit of an app can run within a specified time
  • build tests to verify that method calls throw an exception when invalid data is passed to it
  • define a group of asserts and check whether two iterable objects contain the same data
  • configure a test case to execute only when a specified assumption is satisfied
  • set a block of code to execute when a specified assumption is met
  • summarize the key concepts covered in this course

Overview/Description
Assertions, a collection of utility methods in in JUnit, help assert the pass or fail status of test cases. The focus of this course is on assertions that allow you to set the conditions for the success and failure of test cases and assumptions to control the flow of execution in a test case. Begin with simple assert methods to compare the actual values of fields or return values of methods with their expected values. Then, use assertions that ensure your app's performance by failing a test if it takes too long to run, followed by assert methods that check an exception is thrown when invalid data is passed to a method. Next, use assumptions that check for conditions before executing a code block - effectively serving as control structures. When you're done, you'll have a working knowledge of using assertions in JUnit.

Target

Prerequisites: none

Unit Testing: Executing JUnit Tests

Course Number:
it_jpdtcjdj_05_enus
Lesson Objectives

Unit Testing: Executing JUnit Tests

  • discover the key concepts covered in this course
  • compile and run enabled test cases in your project using Apache Maven
  • use Apache Maven to execute only specific test cases based on class name, method name, or tags
  • compile and run enabled test cases in your project using the JUnit ConsoleLauncher
  • specify test cases to be included or excluded in a test execution launched from the ConsoleLauncher based on class name or tags
  • summarize the key concepts covered in this course

Overview/Description
JUnit, the Java unit testing framework, can be used with an IDE but also with a build system, such as Maven. Furthermore, JUnit ConsoleLauncher, a stand-alone application, can be used to launch the platform from the command line. This course will dive deep into the use of Maven as well as the JUnit ConsoleLauncher to run all and specific test cases in your application. Begin by running all test cases you have written for your app using Maven. Then run specific tests and define groups of tests using JUnit tags. Next, run the tests from the command line. Finally, execute such tests using the JUnit ConsoleLauncher, which can be run from a shell without other tools such as Maven. Upon completing the course, you'll be able to execute JUnit test cases from the command line using Apache Maven and the JUnit ConsoleLauncher.

Target

Prerequisites: none

Unit Testing: Parameterized JUnit Tests

Course Number:
it_jpdtcjdj_04_enus
Lesson Objectives

Unit Testing: Parameterized JUnit Tests

  • discover the key concepts covered in this course
  • apply the RepeatedTest annotation to run a test case multiple times
  • use the ValueSource annotation to run a parameterized test case several times for a set of pre-defined parameters
  • set parameterized tests to run for null and empty parameter values as well as CSV values
  • define a class to apply a transformation to parameters before they are fed into a test case
  • summarize the key concepts covered in this course

Overview/Description
Parameterized tests in JUnit help developers save time by running the same tests repeatedly, using only different inputs, and getting different results. The focus of this course is on scaling test case executions using repeated and parameterized tests. Start by setting a particular test case to run multiple times using the RepeatedTest annotation. Next, move on to defining test cases that can accept parameters. Then, look into different ways in which the parameters can be fed into your test case - from hard-coded values defined in your test class to CSV files and method invocations. Finally, learn how to build a specialized class to pre-process your parameters before being fed into test cases. Upon completion, you'll know how to conduct repeated executions of JUnit test cases with or without parameters.

Target

Prerequisites: none

Close Chat Live